unit Unit1;

interface

uses
  Winapi.Windows,
  Winapi.Messages,
  System.SysUtils,
  System.Variants,
  System.Classes,
  Vcl.Graphics,
  Vcl.Controls,
  Vcl.Forms,
  Vcl.Dialogs,
  Vcl.StdCtrls,

   
  GLS.FileOBJ,
  GLS.SceneViewer,

  GLS.VectorTypes,
  GLS.BaseClasses,
  GLS.Scene,
  GLS.VectorFileObjects,
  GLS.Cadencer,
  GLS.Objects,
  GLS.Coordinates,
  GLS.VectorGeometry;

type
  TForm1 = class(TForm)
    GLScene1: TGLScene;
    GLSceneViewer1: TGLSceneViewer;
    cam: TGLCamera;
    dc: TGLDummyCube;
    GLCadencer1: TGLCadencer;
    ff: TGLFreeForm;
    Button1: TButton;
    pts: TGLPoints;
    procedure GLCadencer1Progress(Sender: TObject; const deltaTime,
      newTime: Double);
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
     
  public
  end;

var
  Form1: TForm1;

  v0:TGLVector=(X:0; Y:2.5; Z:0; W:0);

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var a1:integer;
begin

  ff.LoadFromFile('2.obj');
  ff.Scale.Scale(4/ff.BoundingSphereRadius);
  ff.BuildOctree(2);

end;

procedure TForm1.GLCadencer1Progress(Sender: TObject; const deltaTime,
  newTime: Double);
begin

  dc.Turn(-deltatime*10);

end;

procedure TForm1.Button1Click(Sender: TObject);
var
  a1:integer;
  v1,v,n:TGLVector;

begin
  for a1:=0 to 800 do begin
    SetVector(v1, dc.LocalToAbsolute(
      VectorSubtract(VectorMake(Random*8-3, -2, Random*8-4), v0)));

    if ff.OctreeRayCastIntersect(v0, v1, @v, @n)then
      pts.Positions.Add(dc.AbsoluteToLocal(v));
    end;
end;
end.
